package com.bruce.pattern.behavioral.observer;

import lombok.extern.slf4j.Slf4j;

import java.util.Observable;
import java.util.Observer;

/**
 * 观察者,我来观察朋友,当朋友发送微博后就立刻通知信息给我
 * <p>
 * Created by bruce on 2018/11/10 19:50
 */
@Slf4j
public class Myself implements Observer {

    private String userId;

    public Myself(String userId) {
        this.userId = userId;
    }

    @Override
    public void update(Observable o, Object arg) {
        Friend friend = (Friend) o;
        Weibo weibo = (Weibo) arg;
        log.info(userId + "在" + weibo.getDateTime() + "接收到好友" + friend.getNickname() + "微博,内容是:" + weibo.getContent());
    }
}
